package edu.itcs6112.za.domain;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotEmpty;


@Entity
@Table(name = "customer")
public class Customer implements Serializable {
	
	
	private static final long serialVersionUID = 1L;
	private Long id;
	private int version;
	private String firstName;
	private String middleName;
	private String lastName;
	private String address1;
	private String address2;
	private String city;
	private String state;
	private String zip;
	private String phone;
	private String email;
	private String userName;
	private String password;
	private String user_role;
	
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "CUST_ID")
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	@Version
	@Column(name = "VERSION")
	public int getVersion() {
		return version;
	}
	
	public void setVersion(int version) {
		this.version = version;
	}
	
	
	@NotEmpty(message="{validation.firstname.NotEmpty.message}")
	@Size(min=1, max=40, message="{validation.firstname.Size.message}")
	@Column(name = "CUST_FIRSTNAME")
	public String getFirstName() {
		return firstName;
	}
	
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
			
	@Column(name = "CUST_MIDDLENAME")
	public String getMiddleName() {
		return middleName;
	}
	
	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}
	
	@NotEmpty(message="{validation.lastname.NotEmpty.message}")
	@Size(min=1, max=40, message="{validation.lastname.Size.message}")		
	@Column(name = "CUST_LASTNAME")
	public String getLastName() {
		return lastName;
	}
	
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	
	@NotEmpty(message="{validation.address1.NotEmpty.message}")
	@Size(min=1, max=40, message="{validation.address1.Size.message}")		
	@Column(name = "CUST_ADDR1")
	public String getAddress1() {
		return address1;
	}
	
	public void setAddress1(String address1) {
		this.address1 = address1;
	}
	
		
	@Column(name = "CUST_ADDR2")
	public String getAddress2() {
		return address2;
	}
	
	public void setAddress2(String address2) {
		this.address2 = address2;
	}

	@NotEmpty(message="{validation.city.NotEmpty.message}")
	@Size(min=1, max=20, message="{validation.city.Size.message}")		
	@Column(name = "CUST_CITY")
	public String getCity() {
		return city;
	}
	
	public void setCity(String city) {
		this.city = city;
	}
	
	@NotEmpty(message="{validation.state.NotEmpty.message}")
	@Size(min=1, max=20, message="{validation.state.Size.message}")		
	@Column(name = "CUST_STATE")
	public String getState() {
		return state;
	}
	
	public void setState(String state) {
		this.state = state;
	}
	
	@NotEmpty(message="{validation.zip.NotEmpty.message}")
	@Size(min=1, max=15, message="{validation.zip.Size.message}")		
	@Column(name = "CUST_ZIP")
	public String getZip() {
		return zip;
	}
	
	public void setZip(String zip) {
		this.zip = zip;
	}
	
	@NotEmpty(message="{validation.phone.NotEmpty.message}")
	@Size(min=1, max=35, message="{validation.phone.Size.message}")		
	@Column(name = "CUST_PHONE")
	public String getPhone() {
		return phone;
	}
	
	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	@NotEmpty(message="{validation.email.NotEmpty.message}")
	@Size(min=1, max=50, message="{validation.email.Size.message}")		
	@Column(name = "CUST_EMAIL")
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	@Column(name = "USER_NAME")
	public String getUserName() {
		return userName;
	}
	
	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "PASSWORD")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "USER_ROLE")
	public String getUserRole() {
		return user_role;
	}

	public void setUserRole(String userRole) {
		this.user_role = userRole;
	}
    
	public String toString() {		
		return "Customer - Id: " + id + ", First name: " + firstName 
				+ ", Middle name: " + middleName + ", Last name: " + lastName + ", Address1: " + address1
				+ ", Address2: " + address2 + ", City: " + city + ", State: " + state + ", Zip: " + zip
				+ ", Phone: " + phone + ", Email: " + email;
	}
	
	
}
